package com.anxin.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.anxin.bean.Project;
import com.anxin.dao.ProjectDAO;
import com.anxin.service.ProjectService;
import com.anxin.util.PageListData;

@Service("projectService")
public class ProjectServiceImpl implements ProjectService {
	private ProjectDAO dao;

	@Transactional
	public void save(Project proj) {
		dao.save(proj);
	}

	@Transactional
	public void delete(Project proj) {
		dao.delete(proj);
	}

	@Transactional
	public void delete(Integer id) {
		dao.delete(Project.class, id);
	}

	@Transactional
	public void update(Project proj) {
		dao.update(proj);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public PageListData queryPage(Map param, int pageNum, int pageSize) {
		param.put("start", (pageNum - 1) * pageSize);
		param.put("limit", pageSize);
		return dao.queryPage(Project.class, param, pageNum, pageSize);
	}

	public Project findById(Integer id) {
		return dao.findById(Project.class, id);
	}

	public List<Project> findAll() {
		return dao.findAll(Project.class);
	}

	public ProjectDAO getDao() {
		return dao;
	}

	@Autowired
	public void setProjectDao(ProjectDAO dao) {
		this.dao = dao;
	}
}
